﻿
using System.Data.Entity;
using System.Data.Entity.Migrations;

namespace S4Store.Persistent
{

    internal sealed class ReportingDbMigrationsConfiguration : DbMigrationsConfiguration<S4StoreDataContext>
    {
        public ReportingDbMigrationsConfiguration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }
    }

    public partial class S4StoreDataContext : System.Data.Entity.DbContext
    {
        #region 静态构造方法
        /// <summary>
        /// 初始化
        /// </summary>
        static S4StoreDataContext()
        {
            Database.SetInitializer<S4StoreDataContext>(
                   new MigrateDatabaseToLatestVersion<S4StoreDataContext, ReportingDbMigrationsConfiguration>());   

            //System.Data.Entity.Database.SetInitializer<LXDataContext>(null);
        }
        #endregion
        

         

        #region 构造方法
        /// <summary>
        /// 初始化
        /// </summary>
        public S4StoreDataContext()
            : base("Name=Default")
        {
           
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="nameOrConnectionString">数据库连接</param>
        public S4StoreDataContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
           
        }
        
        #endregion
        
        
        
        #region 创建实体模型
        /// <summary>
        /// 创建实体模型
        /// </summary>
        /// <param name="modelBuilder">实体模型生成器</param>
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            new S4StoreMapping().RegisterTo(modelBuilder);
        }
        #endregion
    }
}